package com.itheima.bayueerhao;

import java.io.*;
import java.net.Socket;

public class Test01 {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 9998);
        FileInputStream is = new FileInputStream("F:\\测试2\\头像.jpg");
        BufferedInputStream bis = new BufferedInputStream(is);
        OutputStream os = socket.getOutputStream();
        BufferedOutputStream bos = new BufferedOutputStream(os);
        byte[] bytes = new byte[8196];
        int lan;
        while ((lan=bis.read(bytes))!=-1){
            bos.write(bytes,0,lan);
        }
        bos.flush();
        socket.shutdownOutput();

        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String s;
        while ((s=br.readLine())!=null){
            System.out.println(s);
        }
        br.close();
        bos.close();
        socket.close();
    }
}
